
$(function(){
	new Vue({
		el:"#shopGoodStockApp",
		data:{
			activeName: 'first',
			fullscreenLoading:false,
			goodLoacalStock:[],
			searchGood:'',
			ids:[],
			form:{
				reason:"",
				uid:"",
			},
			dialogFormVisible:false,
			formLabelWidth:"180px",
		},
		created:function(){
			parent.vueData.$data.hreHtml = "../goodStock/index.html";
			parent.vueData.activeIndex = "6";
			parent.vueData.getLeftNav("6")
			parent.vueData.$data.categoryIndex = 0
			this.getShopList(1)
		},
		methods:{
			getShopList(page){
			   this.fullscreenLoading = true;
			   let param = {
			   	   page: page,
			   }
			   axios({
			   	url: POSTURL.getGoodList,
			   	method: 'post',
			   	data: param
			   }).then(response => {
			   	this.fullscreenLoading = false;
			   	if (response.data.code === 100) {
					this.goodLoacalStock = response.data.result
			   	} else {
			   		this.$message.error(response.data.message);
			   	}
			   }).catch(error => {
			   	this.fullscreenLoading = false;
			   	console.log(error);
			   	this.$message.error('服务器出错!');
			   })
			},
			//通过审核
			handleConfigClick(val){
				this.changeGoodStatus(0,val.uid)
			},
			//拒接审核
			handleDeleteClick(val){
				this.dialogFormVisible = true
				this.form.uid = val.uid
			},
			//确认拒绝
			configRefuse(){
				  if(stringEmpty(this.form.reason)){
					  this.$message.error("请填写拒绝理由");
					  return;
				  }
				  this.dialogFormVisible = false
				  this.changeGoodStatus(2,this.form.uid,this.form.reason)
			},
			
			changeGoodStatus( status ,uid ,reason){
				this.fullscreenLoading = true;
				let param = {
					uid:uid,
					auditState:status
				}
				if( status == 2){
					param.cause  = reason
				}
				axios({
					url: POSTURL.auditGoods,
					method: 'post',
					data: param
				}).then(response => {
					this.fullscreenLoading = false;
					if (response.data.code === 100) {
						this.$message({
							showClose: true,
							message: response.data.message,
							type: 'success'
						});
						if(status == 2){
							this.form = {};
						}
						this.getShopList(1)
						
					} else {
						this.$message.error(response.data.message);
					}
				}).catch(error => {
					this.fullscreenLoading = false;
					console.log(error);
					this.$message.error('服务器出错!');
				})
			},
			handleClick(tab, event) {
				console.log(tab.name);
			},
			beforeHandleCommand(row,command){
			            return {
			                'row': row,
			                'command':command
			            }
			        },
			handleCommand(command){
				console.log(command);
			},
			handlePlatformCommand(command){
				console.log(command);
			},
			handleSelectionChange(val) {
				this.ids = [];
				val.forEach(obj => {
					this.ids.push(obj.uid)
				})
			},
			handleCurrentChange(val) {
				console.log(`当前页: ${val}`);
			},
			toggleSelection(){
				
			}
		    
		}
	})
})